// pages/Nineactivities/Nineactivities.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    is_new_user: false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (e) {
    getApp().page.onLoad(this, e);
    console.log('123123456',e)
    this.user_status();
    if (wx.getStorageSync('ACCESS_TOKEN')) {
      var recommender_id = wx.getStorageSync('recommender_id')
      console.log('已登录',recommender_id)
      if (recommender_id != '' || recommender_id != '0') {
        console.log('已登录有')
        getApp().page.bindParent1(recommender_id)
      }
      if (e.scene) {
        console.log('scene1')
        getApp().page.bindParent1(e.scene)
      } 
      if (e.recommender_id) {
        console.log('recommender_id1')
        getApp().page.bindParent1(e.recommender_id)
      } 
    } else {
      console.log('未登录')
      var recommender_id = wx.getStorageSync('recommender_id')
      console.log('recommender_id==', recommender_id)
      if (e.recommender_id) {
        if (recommender_id == '' || recommender_id == '0') {
          console.log('wu')
          wx.setStorageSync('recommender_id', e.recommender_id)
        }
      }
      if (e.scene) {
        if (recommender_id == '' || recommender_id == '0') {
          console.log('scenewu')
          wx.setStorageSync('recommender_id', e.scene)
        }
      }
    }

  },
  onShow:function(a){
    console.log('onshow',a)
  },
  user_status: function (e) {
    var o = this
    getApp().request({
      url: getApp().api.default.user_status,
      success: function (e) {
        o.setData({
          is_new_user: e.data.is_new_user
        })
      },
      complete: function () {
        getApp().core.hideLoading();
      }
    });
  },
  gm: function (e) {
    wx.navigateTo({
      url: '/pages/new-order-submit/new-order-submit?goumai=1' + "&mch_list=" + '[{"mch_id":0,"goods_list":[{"goods_id":"46","num":1,"attr":[{"attr_group_id":1,"attr_id":1}]}]}]',
    })

  },


  //转发
  onShareAppMessage: function () {
    var t = getApp().getUser()
    getApp().page.onShareAppMessage(this);
    console.log('id',t.id)
    return {
      path: "/pages/Nineactivities/Nineactivities?recommender_id=" + t.id ,
      title: '99活动专享',
    };
  },
})